home *** CD-ROM | disk | FTP | other *** search
/ Enter 2004 August / ENTER.ISO / files / gimp-2.0.5-i586-setup.exe / {app} / share / gimp / 2.0 / scripts / circuit.scm < prev    next >
Encoding:
GIMP Script-Fu Script  |  2004-09-26  |  4.4 KB  |  142 lines

  1. ; The GIMP -- an image manipulation program
  2. ; Copyright (C) 1995 Spencer Kimball and Peter Mattis
  3. ; Circuit board effect
  4. ; Copyright (c) 1997 Adrian Likins
  5. ; aklikins@eos.ncsu.ed
  6. ;
  7. ;  Genrates what looks a little like the back of an old circuit board.
  8. ;  Looks even better when gradmapped with a suitable gradient.
  9. ;
  10. ; This script doesnt handle or color combos well. ie, black/black 
  11. ;  doesnt work..
  12. ;  The effect seems to work best on odd shaped selections because of some
  13. ; limitations in the maze codes selection handling ablity
  14. ;
  15. ;
  16. ; This program is free software; you can redistribute it and/or modify
  17. ; it under the terms of the GNU General Public License as published by
  18. ; the Free Software Foundation; either version 2 of the License, or
  19. ; (at your option) any later version.
  20. ; This program is distributed in the hope that it will be useful,
  21. ; but WITHOUT ANY WARRANTY; without even the implied warranty of
  22. ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  23. ; GNU General Public License for more details.
  24. ; You should have received a copy of the GNU General Public License
  25. ; along with this program; if not, write to the Free Software
  26. ; Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  27.  
  28.  
  29. (define (script-fu-circuit image
  30.                drawable
  31.                mask-size
  32.                seed
  33.                remove-bg
  34.                keep-selection
  35.                seperate-layer)
  36.   (let* (
  37.      (type (car (gimp-drawable-type-with-alpha drawable)))
  38.      (image-width (car (gimp-image-width image)))
  39.      (image-height (car (gimp-image-height image)))
  40.      (old-fg (car (gimp-palette-get-foreground)))
  41.     )
  42.     
  43.     (gimp-image-undo-group-start image)
  44.  
  45.     (gimp-layer-add-alpha drawable)
  46.     
  47.     (if (= (car (gimp-selection-is-empty image)) TRUE)
  48.     (begin
  49.       (gimp-selection-layer-alpha drawable)
  50.       (set! active-selection (car (gimp-selection-save image)))
  51.       (set! from-selection FALSE))
  52.     (begin
  53.       (set! from-selection TRUE)
  54.       (set! active-selection (car (gimp-selection-save image)))))
  55.     
  56.     (set! selection-bounds (gimp-selection-bounds image))
  57.     (set! select-offset-x (cadr selection-bounds))
  58.     (set! select-offset-y (caddr selection-bounds))
  59.     (set! select-width (- (cadr (cddr selection-bounds)) select-offset-x))
  60.     (set! select-height (- (caddr (cddr selection-bounds)) select-offset-y))
  61.     
  62.     (if (= seperate-layer TRUE)
  63.     (begin
  64.       (set! effect-layer (car (gimp-layer-new image
  65.                           select-width
  66.                           select-height
  67.                           type
  68.                           "effect layer"
  69.                           100
  70.                           NORMAL-MODE)))
  71.       
  72.       (gimp-image-add-layer image effect-layer -1)
  73.       (gimp-layer-set-offsets effect-layer select-offset-x select-offset-y)
  74.       (gimp-selection-none image)
  75.       (gimp-edit-clear effect-layer)
  76.       (gimp-selection-load active-selection)
  77.       (gimp-edit-copy drawable)
  78.       
  79.       (let ((floating-sel (car (gimp-edit-paste effect-layer FALSE))))
  80.         (gimp-floating-sel-anchor floating-sel)
  81.         )
  82.       (gimp-image-set-active-layer image effect-layer )))
  83.     (set! active-layer (car (gimp-image-get-active-layer image)))
  84.  
  85.     (if (and
  86.      (= remove-bg TRUE)
  87.      (= old-bg '(0 0 0)))
  88.     (gimp-palette-set-foreground '(0 0 0))
  89.     (gimp-palette-set-foreground '(14 14 14)))
  90.     
  91.     (gimp-selection-load active-selection)
  92.     (plug-in-maze 1 image active-layer 5 5 TRUE 0 seed 57 1)
  93.     (plug-in-oilify 1 image active-layer mask-size 0)
  94.     (plug-in-edge 1 image active-layer 2 1 0)
  95.     (gimp-desaturate active-layer)
  96.     
  97.     (if (and
  98.      (= remove-bg TRUE)
  99.      (= seperate-layer TRUE))
  100.     (begin
  101.       (gimp-by-color-select
  102.        active-layer
  103.        '(0 0 0)
  104.        15
  105.        2
  106.        TRUE
  107.        FALSE
  108.        10
  109.        FALSE)
  110.       (gimp-edit-clear active-layer)))
  111.     
  112.     (gimp-palette-set-foreground old-fg)
  113.     
  114.     (if (= keep-selection FALSE)
  115.     (gimp-selection-none image))
  116.     
  117.     (gimp-image-remove-channel image active-selection)
  118.     (gimp-image-set-active-layer image drawable)
  119.  
  120.     (gimp-image-undo-group-end image)
  121.  
  122.     (gimp-displays-flush)))
  123.  
  124. (script-fu-register "script-fu-circuit"
  125.             _"<Image>/Script-Fu/Render/_Circuit..."
  126.             "Fills the current selection with something that looks 
  127.                      vaguely like a circuit board."
  128.             "Adrian Likins <adrian@gimp.org>"
  129.             "Adrian Likins"
  130.             "10/17/97"
  131.             "RGB* GRAY*"
  132.             SF-IMAGE "Image" 0
  133.             SF-DRAWABLE "Drawable" 0
  134.             SF-ADJUSTMENT _"Oilify Mask Size" '(17 3 50 1 10 0 1)
  135.             SF-ADJUSTMENT _"Circuit Seed" '(3 1 3000000 1 10 0 1)
  136.             SF-TOGGLE _"No Background (only for separate layer)" FALSE
  137.             SF-TOGGLE _"Keep Selection" TRUE
  138.             SF-TOGGLE _"Separate Layer" TRUE)
  139.